package ar.com.sne.model.bo.geo;

import java.util.ArrayList;
import java.util.List;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.log4j.Logger;

import ar.com.sne.bean.BaseBO;
import ar.com.sne.model.dao.factory.GeoDAOFactory;

/**
 * GeoTipoMail
 * Clase encargada de encapsular la logica de geografia para tipo de mails.
 */

@Entity
@Table(name = "GEO_TIPO_MAILS", catalog = "sneweb")
public class GeoTipoMail extends BaseBO {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String tipo;
	private List<GeoMail> geoMailses = new ArrayList<GeoMail>();

	@Transient
	Logger log = Logger.getLogger(GeoTipoMail.class);
	
	/*
	 * Contructores 
	 */
	
	public GeoTipoMail() {
		super();
	}
	
	/*
	 * Getter & Listters
	 */
	
	@Column(name = "tipo", nullable = false, length = 30)
	public String getTipo() {
		return this.tipo;
	}

	public void setTipo(String tipo) {
		this.tipo = tipo;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "geoTipoMails")
	public List<GeoMail> getGeoMailses() {
		return this.geoMailses;
	}

	public void setGeoMailses(List<GeoMail> geoMailses) {
		this.geoMailses = geoMailses;
	}

	/*
	 * Metodos de Clase
	 */
	
	public static GeoTipoMail getById(Long id){
		return (GeoTipoMail) GeoDAOFactory.getGeoTipoMailDAO().getById(id);
	}
	
	public static GeoTipoMail getByIdNull(Long id) {
		return (GeoTipoMail) GeoDAOFactory.getGeoTipoMailDAO().getByIdNull(id);
	}
	
	public static List<GeoTipoMail> getList() {
		return (List<GeoTipoMail>) GeoDAOFactory.getGeoTipoMailDAO().getList();
	}
	
	public static List<GeoTipoMail> getListActivos() {			
		return (List<GeoTipoMail>) GeoDAOFactory.getGeoTipoMailDAO().getListActiva();
	}
}
